package com.prs.crm.domain.oa;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.Attachment;
import com.prs.crm.domain.BaseEntity;
import com.prs.crm.domain.hr.Person;


@Entity
@Table(name="oa_mailitem")
public class MailItem extends BaseEntity{
	
	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	
	private String title;
	
	@Lob
	private String content;
	
	private String sender;
	
	/**
	 * 原始邮件编号
	 */
	private String messageId;
	
	
	@ManyToOne
	private Person reciver;
	
	
	private String sendTo;
	/**
	 * 抄送人
	 */
	private String cc;
	
	/**
	 * 密送人
	 */
	private String bcc;
	
	@ManyToOne
	private MailBox mailBox;
	
	private Date reciveDate;
	
	private Date sendDate;
	
	@ManyToMany
	@OrderBy
	@Cascade({org.hibernate.annotations.CascadeType.ALL,org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<Attachment> attachs;
	
	private int readStatus;
	
	private int type;

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getId() {
		return id;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getTitle() {
		return title;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getContent() {
		return content;
	}

	public void setSender(String sender) {
		this.sender = sender;
	}

	public String getSender() {
		return sender;
	}

	public void setMailBox(MailBox mailBox) {
		this.mailBox = mailBox;
	}

	public MailBox getMailBox() {
		return mailBox;
	}

	public void setReciveDate(Date reciveDate) {
		this.reciveDate = reciveDate;
	}

	public Date getReciveDate() {
		return reciveDate;
	}

	public void setSendDate(Date sendDate) {
		this.sendDate = sendDate;
	}

	public Date getSendDate() {
		return sendDate;
	}

	public void setAttachs(Set<Attachment> attachs) {
		this.attachs = attachs;
	}

	public Set<Attachment> getAttachs() {
		return attachs;
	}
	
	public void addAttach(Attachment attach)
	{
		if (attachs==null)
			attachs = new HashSet<Attachment>();
		attachs.add(attach);
	}

	public void setReadStatus(int readStatus) {
		this.readStatus = readStatus;
	}

	public int getReadStatus() {
		return readStatus;
	}

	public void setCc(String cc) {
		this.cc = cc;
	}

	public String getCc() {
		return cc;
	}

	public void setBcc(String bcc) {
		this.bcc = bcc;
	}

	public String getBcc() {
		return bcc;
	}

	public void setReciver(Person reciver) {
		this.reciver = reciver;
	}

	public Person getReciver() {
		return reciver;
	}

	public void setMessageId(String messageId) {
		this.messageId = messageId;
	}

	public String getMessageId() {
		return messageId;
	}

	public void setType(int type) {
		this.type = type;
	}

	public int getType() {
		return type;
	}

	public void setSendTo(String sendTo) {
		this.sendTo = sendTo;
	}

	public String getSendTo() {
		return sendTo;
	}



}
